import { defineStore } from "pinia";
import { UserState } from "@/stores/interface";
import piniaPersistConfig from "@/stores/helper/persist";
import { Login } from "@/api/interface/index";

export const useUserStore = defineStore({
  id: "geeker-user",
  state: (): UserState => ({
    token: "",
    userInfo: {
      companyId: 0,
      companyName: "",
      companyVersion: "",
      companyVersionExpiryTime: "",
      employeeId: 0,
      employeeName: "",
      employeeIsAdmin: false,
      employeeRoleIds: [],
      employeePermissions: []
    }
  }),
  getters: {},
  actions: {
    // Set Token
    setToken(token: string) {
      this.token = token;
    },
    // Set setUserInfo
    setUserInfo(userInfo: Login.UserInfo) {
      this.userInfo = userInfo;
    }
  },
  persist: piniaPersistConfig("geeker-user")
});
